import Vue from 'vue';

import http from '@src/util/HttpUtil';

import Main from './index.vue';

Vue.prototype.$http = http;

try {
  //服务商注册如果是手机端需要跳转到手机端的页面
  if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
    let origin = window.location.origin;
    let params = window.location.search
    window.location.replace(`${origin}/client/mobile/#/serviceProvider${params}`)
  }
} catch (e) {
  console.error(e)
}


// 处理注入的参数
let initData = {};

try {
  initData = JSON.parse(window._init || '{}') || {};
} catch (error) {
  console.error(error);
  console.error('no init data')
}

/*const App = new Vue({
  el: '#app',
  provide: {
    initData: Object.freeze(initData)
  },
  render: h => h(Main),
});*/


let app = {
  provide: {
    initData: Object.freeze(initData),
  },
  render: h => h(Main)
}

export default app;